package com.market.sqltemp;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.market.util.DataConnection;
import com.mysql.jdbc.PreparedStatement;


public class SqlTrans {
	Connection conn = null;
	Statement ps = null;
	ResultSet rs = null;
	DataConnection dt = new DataConnection();
	public SqlTrans(){
		conn = dt.getConnection("markets");
		try {
			conn.setAutoCommit(false);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	
	//单挑SQL插入
	public int insSql(String sql){
		int i = 0;
		try {
			ps = conn.createStatement();
			i = ps.executeUpdate(sql);
			conn.commit();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			try {
				conn.rollback();
			} catch (SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		}
		return i;
	}
}
